const md = require('../../utils/md5.js');
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
  
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    that.setData({
      userinfo: wx.getStorageSync('userinfo')
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  formSubmit: function (e) {
    console.log('form发生了submit事件，携带数据为：', e.detail.value);
    var that = this;
    var pwd = e.detail.value.pwd;
    // return;
    if (pwd.length == 0) {
      wx.showModal({
        title: '',
        content: '登录密码不能为空',
      })
      return;
    }
    // wx.navigateTo({
    //   url: '/pages/changepwd2/changepwd2?pwd=' + pwd,
    // })
    // return;
    // 获取时间戳
    wx.showLoading({
      title: '请稍候...',
    })
    var apinameIsMeb = "/Action/PK01/SMSVerifySend";
    var timestamp = new Date().getTime();
    timestamp = parseInt(timestamp / 1000);
    var md5IsMeb = md.hexMD5(app.server.appid + timestamp + apinameIsMeb + app.server.appkey);
    wx.request({
      //后台接口地址
      url: app.server.url + apinameIsMeb,
      data: {
        sign: md5IsMeb,
        appid: app.server.appid,
        tmsp: timestamp,
        mobile: that.data.userinfo.Tel
      },
      method: 'POST',
      header: { 'content-type': 'application/x-www-form-urlencoded' },
      success: function (res) {
        // console.log(res);
        // if (res.data.data == true) {
         
        // }
      },
      complete:function(res){
        wx.hideLoading();
        wx.navigateTo({
          url: '/pages/loginpwd2/loginpwd2?pwd=' + pwd,
        })
      }
    })

  },
})